@extends('layouts.appDomain')

@section('script')
    <script>
        $(document).ready(function () {
            // $('#pid').val(GetQueryString('rec'));
            let rec_P=GetQueryString('rec');
            if (rec_P>0){
                localStorage.setItem('rec_P',rec_P);
            }
            $('#pid').val(localStorage.getItem('rec_P')??0);
        })
    </script>
@endsection

@section('content')

    <div class="container py-5">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card panel">
                    <div class="card-header">注册</div>

                    <div class="card-body">
                        @if(session('player'))
                            <div class="alert alert-warning" role="alert">
                                当前已经登录，无需重复注册
                            </div>
                        @else
                            <form method="POST" action="{{ url('register') }}">
                                @csrf

                                <input type="hidden" name="pid" id="pid" value="0">

                                <div class="form-group row">
                                    <label for="username" class="col-md-4 col-form-label text-md-right">用户名</label>

                                    <div class="col-md-6">
                                        <input id="username" type="text" class="form-control @error('username') is-invalid @enderror" name="username" value="{{ old('username') }}" required autocomplete="username" autofocus placeholder="通行证名称">

                                        @error('username')
                                        <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                        @enderror
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="password" class="col-md-4 col-form-label text-md-right">密码</label>

                                    <div class="col-md-6">
                                        <input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required>

                                        @error('password')
                                        <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                        @enderror
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="password2" class="col-md-4 col-form-label text-md-right">确认密码</label>

                                    <div class="col-md-6">
                                        <input id="password2" type="password" class="form-control @error('password2') is-invalid @enderror" name="password2" required>

                                        @error('password2')
                                        <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                        @enderror
                                    </div>
                                </div>


                                <div class="form-group row mb-0">
                                    <div class="col-md-8 offset-md-4">
                                        <button type="submit" class="btn btn-primary">
                                            注册
                                        </button>
                                    </div>
                                </div>
                            </form>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
